package com.xlh.lib.Core;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.xlh.Utils.Constant;
import com.xlh.Utils.FUti;
import com.xlh.Utils.HtmlHandler;
import com.xlh.Utils.MudProtocol;
import com.xlh.Utils.ProtocolParser;
import com.xlh.bean.CharBean;
import com.xlh.bean.ProBean;
import com.xlh.bean.TitleBean;
import com.xlh.fgs.UserFg;

import com.xlh.outside.MainActivity;
import com.xlh.outside.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fang on 2018-01-06.
 */

public class RenderCore {

    private Context context;

    public RenderCore(Context context) {
        this.context = context;
    }




    /**
     * 验证通过
     * @param
     */
    public void renderVerifythroughX(String d){

        MainActivity activity =  ((MainActivity) context);

        if (activity.isReconnectStatus()) {
            if (activity.getApp().getActiveUser()==null || activity.getApp().getActiveUserPwd()==null){
                Toast.makeText(context, "重连时，账号或密码句柄错误!", Toast.LENGTH_LONG).show();
                return;
            }
            if (!activity.getApp().getActiveUser().isEmpty() && !activity.getApp().getActiveUserPwd().isEmpty()) {


                //账号║密码║密文║手机
                activity.mSocketClient.sendMsg( String.format("%s,%s,%s,%s",
                        activity.getApp().getActiveUser(),
                        activity.getApp().getActiveUserPwd(),
                        activity.getApp().getWzkey(),
                        activity.getApp().getActiveUserPhone()
                        )
                );
                //必须刷新周围环境,避免 出现错误的控件
                //因为重连后 物品ID不一样了...但是物件栏的控件绑定的ID还是重连之前的物件ID
                //mSocketClient.sendMsg("look");
            }
        } else {


            if (!activity.getApp().getActiveUser().isEmpty() && !activity.getApp().getActiveUserPwd().isEmpty()) {
                //账号║密码║密文║手机
                activity.mSocketClient.sendMsg( String.format("%s,%s,%s,%s",
                        activity.getApp().getActiveUser(),
                        activity.getApp().getActiveUserPwd(),
                        activity.getApp().getWzkey(),
                        activity.getApp().getActiveUserPhone()
                        )
                );

            }
        }


    }











}
